﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="AhciCdDrive"
	type="http://metalx.org/Storage/Ahci/AhciCdDrive"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:var="http://metalx.org/Variable"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:int="http://metalx.org/i386/Functions/Integer"
	xmlns:bool="http://metalx.org/i386/Functions/Boolean"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:cd="http://metalx.org/i386/Functions/CdDrive"
	xmlns:hex="http://metalx.org/i386/Functions/Hexadecimal"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:pcif="http://metalx.org/i386/Functions/Pci"
	xmlns:pata="http://metalx.org/Pc/Pata/Ports"
	xmlns:status="http://metalx.org/Pc/Pata/Status"
	xmlns:drive="http://metalx.org/Pc/Pata/DriveSelect"
	xmlns:cmd="http://metalx.org/Pc/Pata/Commands"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands"
	xmlns:imm="http://metalx.org/Intel/80386/Immediate"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:shift="http://metalx.org/Intel/80386/Shift"
	xmlns:logic="http://metalx.org/Intel/80386/Logic"
	xmlns:port="http://metalx.org/Pc/Ports"
	xmlns:pci="http://metalx.org/Pc/Pci/Ports"
	xmlns:cfg="http://metalx.org/Pc/Pci/Configuration"
	xmlns:dsk="http://metalx.org/Pc/Floppy/Ports"
	xmlns:fcmd="http://metalx.org/Pc/Floppy/Commands"
	xmlns:fdr="http://metalx.org/Pc/Floppy/DataRate"
	xmlns:fdo="http://metalx.org/Pc/Floppy/DigitalOutput"
	xmlns:fst="http://metalx.org/Pc/Floppy/Status"
	xmlns:kbd="http://metalx.org/Pc/Keyboard"
	xmlns:ahci="http://metalx.org/Intel/Ahci/Registers"
	xmlns:ports="http://metalx.org/Intel/Ahci/Ports">

	<cls:field name="Device" type="http://metalx.org/Pci/PciDevice" offset="0"/>
	<cls:field name="Port" type="http://metalx.org/Byte" offset="4"/>

	<cls:method name="GetSignature" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyOperandToRegister8/>
		<op:BL-SIAddressPlusImmediate8/>
		<byte>4</byte>

		<cpu:MathImmediateToOperandFunction/>
		<math:AndWithBXRegister/>
		<hex>000000ff</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftBXRegisterLeft/>
		<byte>7</byte>

		<pcif:GetBaseAddress5/>

		<cpu:AndAXWithImmediate/>
		<hex>fffffff0</hex>

		<cpu:AddImmediateToAX/>
		<hex>00000100</hex>

		<cpu:AddRegisterToOperand/>
		<op:BX-AXRegister/>

		<cpu:CopyOperandToRegister/>
		<op:AX-AXAddressPlusImmediate8/>
		<hex>24</hex>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetFrameTableAddress" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyOperandToRegister8/>
		<op:BL-SIAddressPlusImmediate8/>
		<byte>4</byte>

		<cpu:MathImmediateToOperandFunction/>
		<math:AndWithBXRegister/>
		<hex>000000ff</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftBXRegisterLeft/>
		<byte>7</byte>

		<pcif:GetBaseAddress5/>

		<cpu:AndAXWithImmediate/>
		<hex>fffffff0</hex>

		<cpu:AddImmediateToAX/>
		<hex>00000100</hex>

		<cpu:AddRegisterToOperand/>
		<op:BX-AXRegister/>

		<cpu:CopyOperandToRegister/>
		<op:AX-AXAddressPlusImmediate8/>
		<hex>08</hex>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetCommandTableAddress" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyOperandToRegister8/>
		<op:BL-SIAddressPlusImmediate8/>
		<byte>4</byte>

		<cpu:MathImmediateToOperandFunction/>
		<math:AndWithBXRegister/>
		<hex>000000ff</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftBXRegisterLeft/>
		<byte>7</byte>

		<pcif:GetBaseAddress5/>

		<cpu:AndAXWithImmediate/>
		<hex>fffffff0</hex>

		<cpu:AddImmediateToAX/>
		<hex>00000100</hex>

		<cpu:AddRegisterToOperand/>
		<op:BX-AXRegister/>

		<cpu:CopyOperandToRegister/>
		<op:AX-AXAddress/>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetStatus" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyOperandToRegister8/>
		<op:BL-SIAddressPlusImmediate8/>
		<byte>4</byte>

		<cpu:MathImmediateToOperandFunction/>
		<math:AndWithBXRegister/>
		<hex>000000ff</hex>

		<cpu:ShiftRegisterByImmediate8Function/>
		<shift:ShiftBXRegisterLeft/>
		<byte>7</byte>

		<pcif:GetBaseAddress5/>

		<cpu:AndAXWithImmediate/>
		<hex>fffffff0</hex>

		<cpu:AddImmediateToAX/>
		<hex>00000118</hex>

		<cpu:AddRegisterToOperand/>
		<op:BX-AXRegister/>

		<cpu:CopyOperandToRegister/>
		<op:AX-AXAddress/>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToString" type="http://metalx.org/String">
		<cpu:CopyImmediateToDI/>
		<addressOf ref="deviceName" type="Absolute32"/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<var:string id="deviceName">AHCI CD-ROM Drive</var:string>
		
		<!--<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:DX-SIAddress/>

		<cpu:CopyOperandToRegister8/>
		<op:AL-SIAddressPlusImmediate8/>
		<byte>4</byte>

		<cd:GetModelNumber/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>-->
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>
</cls:class>